// =====================================================================================
//  Copyright (C) 2024 by Jiaxing Shao. All rights reserved

//  文 件 名:  ShaderProgram.h
//  作    者:  Jiaxing Shao, 980853650@qq.com
//  创建时间：  2024-08-01 21:58
//  描    述:  
// =====================================================================================
#pragma once

#include <unordered_map>
#include <string>

#include <glm/glm.hpp>

class ShaderProgram {
public:
    ShaderProgram(const std::string &vsPath, const std::string &fsPath);
    ~ShaderProgram();

private:
    std::string  loadShaderSource(std::string filepath);
    unsigned int compileShader(unsigned int type, const std::string &source);
    unsigned int createShaderProgram(const std::string &vertexShader, const std::string &fragmentShader);
    int          getUniformLocation(const std::string &name);

public:
    void setUniform1i(const std::string &name, int value);
    void setUniform1f(const std::string &name, float value);
    void setUniform3f(const std::string &name, float x, float y, float z);
    void setUniformVec3f(const std::string &name, const glm::vec3 &vec);
    void setUniformMat4fv(const std::string &name, const glm::mat4 &matrix);

public:
    void bind();
    void unbind();

private:
    unsigned int                         m_rendererId;
    std::unordered_map<std::string, int> m_uniformLocationCache;
};